package com.yenlien.traceyun.business.dao;

import com.yenlien.traceyun.business.entity.Warehouse;
import com.yenlien.traceyun.business.entity.WarehousePart;
import com.yenlien.traceyun.webase.dao.BaseJpaDao;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author: bigwangy@sina.com
 * @create: 2020-12-21
 * @description:
 **/
public interface WarehousePartDao extends BaseJpaDao<WarehousePart> {

    public List<WarehousePart> findByWarehouseId(String warehouseId);

    public void deleteByWarehouseId(String warehouseId);

    public List<WarehousePart> findByCompanyId(String companyId);

    @Query(value = "select id,company_id,createtime,user_id,code,name,warehouse_id,base_soil_id from t_warehouse_part  where base_soil_id=?1", nativeQuery = true)
    List<WarehousePart> findByBasesoilId(String baseSoilId);

    @Transactional
    @Modifying
    @Query(value = "delete from t_warehouse_part  where base_soil_id=?1", nativeQuery = true)
    void deleteByBaseSoilId(String baseSoilId);
}
